package com.example.futureai.config;

import com.example.futureai.config.propertise.VectorStorePropertiesConfig;
import com.example.futureai.constants.SpringAIConst;
import org.springframework.ai.embedding.BatchingStrategy;
import org.springframework.ai.ollama.OllamaEmbeddingModel;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.vectorstore.redis.RedisVectorStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPooled;

/**
 * @ClassName: VectorStoreConfig
 * @Description:
 * @Author: YourName
 * @Date: 2025/2/25
 */


@Configuration
public class VectorStoreConfig {

   /* @Autowired
    @Qualifier("springAiJedisPooled")
    private JedisPooled springAiJedisPooled;

    @Autowired
    private VectorStorePropertiesConfig vpc;

//    @Autowired
//    @Qualifier("myOpenAiEmbeddingModel")
//    private OpenAiEmbeddingModel embeddingModel;

    @Autowired
    @Qualifier("myOllamaEmbeddingModel")
    private OllamaEmbeddingModel embeddingModel;

    @Autowired
    @Qualifier("myBatchingStrategy")
    private BatchingStrategy batchingStrategy;

    @Bean("myVectorStore")
    public VectorStore vectorStore() {
        return RedisVectorStore.builder(springAiJedisPooled, embeddingModel)
                .indexName(vpc.getIndexName())
                .prefix(vpc.getPrefix())
                .embeddingFieldName("embedding")      // 向量字段名，默认 embedding
                .contentFieldName("content")          // 存储的原始文本内容
                .initializeSchema(vpc.getInitializeSchema())//是否初始化索引配置信息


                .metadataFields(
                        RedisVectorStore.MetadataField.text(SpringAIConst.VectorStore.METADATA_DOC_ID),   // 存储的元数据信息
                        RedisVectorStore.MetadataField.text(SpringAIConst.VectorStore.METADATA_DOC_NAME)  // 存储的元数据信息
                ).build();
    }*/
}
